package com.windystory.app.antdesign;

import android.view.View;
import android.widget.ImageView;

import androidx.annotation.Nullable;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.windystory.wslibrary.base.activity.BaseRefreshActivity;

import java.util.ArrayList;
import java.util.List;

public class MainActivity extends BaseRefreshActivity<String> {
    private List<String> l = new ArrayList<>();
    private ImageView back;

    @Override
    protected int initTitleLayout() {
        return R.layout.layout_view_title;
    }

    @Override
    protected List<String> setList() {
        return l;
    }

    @Override
    protected int setEmptyView() {
        return R.layout.layout_skeleton;
    }

    @Override
    protected RecyclerView.LayoutManager setLayoutManager() {
        return new LinearLayoutManager(this);
    }

    @Override
    protected BaseQuickAdapter setAdapter(List<String> strings) {
        return new ListItemAdapter(l);
    }

    @Override
    protected void getData(int page) {
        onLoadData2Finish();
        for (int i = 0; i < 100; i++) {
            l.add(i + "");
        }
        adapter.notifyDataSetChanged();

       readyGoThenKill(TestActivity.class);
    }


    @Override
    protected boolean setEnableSwipeBack() {
        return true;
    }

    @Override
    protected void initCustomOpration() {
        back = (ImageView) findViewById(R.id.back);
        back.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                finish();
            }
        });
    }


    public class ListItemAdapter extends BaseQuickAdapter<String, BaseViewHolder> {

        public ListItemAdapter(@Nullable List<String> data) {
            super(R.layout.list_item, data);
        }

        @Override
        protected void convert(BaseViewHolder helper, String item) {
            helper.setText(R.id.item, item);
        }
    }


}
